//
//  SHBankCarCell.m
//  JiFengDaRen
//
//  Created by SH_iOS on 2017/6/23.
//  Copyright © 2017年 SH_iOS. All rights reserved.
//
#import "BankCardModel.h"
#import "SHBankCarCell.h"

@implementation SHBankCarCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        
        [self configUI];
        
    }
    return self;
}

- (void)configUI{
    
    self.icon = [[UIImageView alloc]init];
    [self.contentView addSubview:self.icon];
    self.nameLabel = [[UILabel alloc]init];
    self.nameLabel.font = KSystemFont(__I6Width(14));
    self.nameLabel.textColor = [UIColor colorWithHexString:@"#333333"];
    [self.contentView addSubview:self.nameLabel];
    self.contentLabel = [[UILabel alloc]init];
    self.contentLabel.font = KSystemFont(__I6Width(13));
    self.contentLabel.textColor = [UIColor colorWithHexString:@"#999999"];
    [self.contentView addSubview:self.contentLabel];
    
    UIView *line = [[UIView alloc]init];
    line.backgroundColor = KLINECOLOR;
    [self.contentView addSubview:line];
    [line mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.mas_equalTo(self.contentView.mas_left).with.offset(__I6Width(0));
        make.right.mas_equalTo(self.contentView.mas_right).with.offset(__I6Width(0));
        make.height.mas_equalTo(__I6Height(0.5));
        make.bottom.mas_equalTo(self.contentView.mas_bottom).with.offset(__I6Height(0));
    }];

    
    self.isAuthLabel = [[UILabel alloc]initWithFrame:CGRectMake(KScreenWidth - __I6Width(135),__I6Height(55)/2 - __I6Height(20)/2,__I6Width(120),__I6Height(20))];
    self.isAuthLabel.textAlignment = NSTextAlignmentRight;
    self.isAuthLabel.font = KSystemFont(__I6Width(13));
    self.isAuthLabel.textColor = KREDCOLOR;
    [self addSubview:self.isAuthLabel];
    
    
    self.default_useLabel = [[UILabel alloc]initWithFrame:CGRectMake(KScreenWidth - __I6Width(135),__I6Height(55) - __I6Height(12),__I6Width(120),__I6Height(12))];
    self.default_useLabel.textAlignment = NSTextAlignmentRight;
    self.default_useLabel.font = KSystemFont(__I6Width(11));
    self.default_useLabel.textColor =  [UIColor colorWithHexString:@"#999999"];
    [self addSubview:self.default_useLabel];
    
}
- (void)layoutSubviews{
    [self.icon mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.mas_equalTo(__I6Width(5));
        make.height.mas_equalTo(__I6Height(5));
        make.left.mas_equalTo(self.mas_left).with.offset(__I6Width(0));
        make.centerY.mas_equalTo(self.mas_centerY);
    }];
    
    [self.nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.mas_equalTo(__I6Width(200));
        //        make.height.mas_equalTo(__I6Height(14));
        make.left.mas_equalTo(self.icon.mas_right).with.offset(__I6Width(15));
        //make.centerY.mas_equalTo(self.mas_centerY);
        make.top.mas_equalTo(self.mas_top).with.offset(__I6Height(10));
    }];
    
    [self.contentLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.mas_equalTo(__I6Width(200));
        make.left.mas_equalTo(self.icon.mas_right).with.offset(__I6Width(15));
        make.top.mas_equalTo(self.nameLabel.mas_bottom).with.offset(__I6Height(5));
    }];
    
    
    
}
- (void)setModel:(BankCardModel *)model{
    
    //self.icon.image = [UIImage imageNamed:model.image];
    self.contentLabel.text =  model.bank_card_code;
    if(model.using_choices == 2){
        if (model.auth_4_status) {
            
            self.isAuthLabel.text = @"";
            
        }else{
            
            self.isAuthLabel.text = @"审核失败";
            
        }

    }else{
        if (model.is_auth == 1) {
            self.isAuthLabel.text = @"";
            
        }else if(model.is_auth == 5){
            self.isAuthLabel.text = @"审核中";

        }else{
            
            if (model.auth_4_status) {
                
                self.isAuthLabel.text = @"";
                
            }else{
                
                self.isAuthLabel.text = @"审核失败";
                
            }

        }
    }
    
    
    
    if(model.default_use){
        self.default_useLabel.text = @"默认收款卡";
 
    }else{
        self.default_useLabel.text = @"设为收款卡";

    }

    if(model.using_choices == 1){
        if(model.is_auth == 1 || model.is_auth == 5){
            self.nameLabel.text = [NSString stringWithFormat:@"%@(杉德)", model.bank_name];
            
        }else{
            self.nameLabel.text =  model.bank_name;
            
        }

    }else{
        self.nameLabel.text =  model.bank_name;

    }
    
}


- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
    if (selected) {
        self.backgroundColor = [UIColor colorWithWhite:242.f/255.f alpha:1];
    }else{
        self.backgroundColor = [UIColor whiteColor];

    }

    // Configure the view for the selected state
}

@end
